package com.wanxing.main;

import java.util.ArrayList;
import java.util.List;

import com.zhny.wxginger.R;

import android.app.Activity;
import android.graphics.YuvImage;
import android.os.Bundle;
import android.view.Display;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;

public class Dialog_time_Activity extends Activity {

	PickerView wateringYear, wateringMonth, wateringDay, wateringHour,
			wateringMinute;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.dialog_time);

		WindowManager m = getWindowManager();
		Display d = m.getDefaultDisplay(); // Ϊ��ȡ��Ļ����

		LayoutParams p = getWindow().getAttributes(); // ��ȡ�Ի���ǰ�Ĳ���ֵ
		p.height = (int) (d.getHeight() * 0.6); // �߶�����Ϊ��Ļ��1.0
		p.width = (int) (d.getWidth() * 0.6); // �������Ϊ��Ļ��0.8
		p.alpha = 1.0f; // ���ñ���͸����
		p.dimAmount = 0.0f; // ���úڰ���

		getWindow().setAttributes(p); // ������Ч
		getWindow().setGravity(Gravity.CENTER);

		wateringYear = (PickerView) findViewById(R.id.p_wateringyear);
		wateringMonth = (PickerView) findViewById(R.id.p_wateringmonth);
		wateringDay = (PickerView) findViewById(R.id.p_wateringday);
		wateringHour = (PickerView) findViewById(R.id.p_wateringhour);
		wateringMinute = (PickerView) findViewById(R.id.p_wateringminute);

		// ������Ϊ�������ʱ��Ŀ�ֱ���������Դ
		List<String> year = new ArrayList<String>();// ���year���ֵ�����
		for (int i = 0; i < 41; i++)// 0~40
		{
			year.add(i < 10 ? "0" + i : "" + i);
		}
		List<String> month = new ArrayList<String>();// ���month���ֵ�����
		for (int i = 1; i < 13; i++)// 1~12
		{
			month.add(i < 10 ? "0" + i : "" + i);
		}
		List<String> day = new ArrayList<String>();// ���day���ֵ�����
		for (int i = 1; i < 32; i++)// 1~31
		{
			day.add(i < 10 ? "0" + i : "" + i);
		}
		List<String> hour = new ArrayList<String>();// ���hour���ֵ�����
		for (int i = 0; i < 25; i++)// 0~24
		{
			hour.add(i < 10 ? "0" + i : "" + i);
		}
		List<String> minute = new ArrayList<String>();// ���minute���ֵ�����
		for (int i = 0; i < 60; i++)// 0~59
		{
			minute.add(i < 10 ? "0" + i : "" + i);
		}

		wateringYear.setData(year);
		wateringMonth.setData(month);
		wateringDay.setData(day);
		wateringHour.setData(hour);
		wateringMinute.setData(minute);
		wateringYear.setOnSelectListener(new PickerView.onSelectListener() {
			public void onSelect(String text) {
				// nyear = text;
			}
		});
		wateringMonth.setOnSelectListener(new PickerView.onSelectListener() {
			public void onSelect(String text) {

				// nmonth = text;
				// ��߿���дѡ���¼�
			}
		});
		wateringDay.setOnSelectListener(new PickerView.onSelectListener() {
			public void onSelect(String text) {
				// nday = text;
				// ��߿���дѡ���¼�
			}
		});
		wateringHour.setOnSelectListener(new PickerView.onSelectListener() {
			public void onSelect(String text) {
				// nhour = text;

			}
		});
		wateringMinute.setOnSelectListener(new PickerView.onSelectListener() {
			public void onSelect(String text) {
				// nmintue = text;

			}
		});
	}
}
